#include "devUsart.h"

void init_debug(void)
{
  
  uart3_dev_init( 115200, 
                  USART_WordLength_8b, 
                  USART_StopBits_1, 
                  USART_Parity_No, 
                  USART_HardwareFlowControl_None);
}

void debug_put_ch(int ch)
{
  if (ch == '\n')  {
    while (!(USART3->SR & 0x0080));
    USART3->DR = 0x0D;
  }
  if (ch == '\r')  {
    while (!(USART3->SR & 0x0080));
    USART3->DR = 0x0A;
  }
  while (!(USART3->SR & 0x0080));
  USART3->DR = (ch & 0xFF);
  return (ch);
}

int debug_get_ch(void)
{
  int ch = -1;
  return ch;
}

